package de.tum.in.eist.poll.client.gui;
import java.util.Date;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.datepicker.client.DateBox;



public class DateSelectorPanel extends WidgetContainer {

	private DateBox dateTo;
	private DateBox dateFrom;
	private Label dateFromLabel;
	private Label dateToLabel;
	private Label errorLabel;
	private Button selectButton;
	private HorizontalPanel datePanel;
	private HorizontalPanel selectPanel;
	private VerticalPanel mainPanel;
	
	public DateSelectorPanel() {
		super(false, true);
		init();
		addContent();
	}

	private void addContent() {
		datePanel.add(dateFromLabel);
		datePanel.add(dateFrom);
		datePanel.add(dateToLabel);
		datePanel.add(dateTo);
		mainPanel.add(datePanel);
		selectPanel.add(errorLabel);
		selectPanel.add(selectButton);
		mainPanel.add(datePanel);
		mainPanel.add(selectPanel);
		add(mainPanel);
	}

	private void init() {
		dateTo = new DateBox();
		dateFrom = new DateBox();
		dateFromLabel = new Label("Date from");
		dateToLabel = new Label("Date to");	
		errorLabel = new Label();
		selectButton = new Button("Select");
		datePanel = new HorizontalPanel();
		selectPanel = new HorizontalPanel();
		mainPanel = new VerticalPanel();
		// Add styles
		mainPanel.addStyleName("lectureForm");
		datePanel.addStyleName("containerPanelForm");
		selectPanel.addStyleName("containerPanelForm");
		dateFrom.addStyleName("dateBox");
		dateTo.addStyleName("dateBox");
		dateFromLabel.addStyleName("standardLabel");
		dateToLabel.addStyleName("standardLabel");
		errorLabel.addStyleName("errorLabel");
		selectButton.addStyleName("standardButton");
	}
	
	public Date getDateFrom() {
		return dateFrom.getValue();
	}
	
	public Date getDateTo() {
		return dateTo.getValue();
	}

	public Button getSelectButton() {
		return selectButton;
	}
	
	public Label getErrorLabel() {
		return errorLabel;
	}
}
